import type { ObjectDirective } from 'vue'
import { useUser } from '@/store/modules/user'
export const hasPermi: ObjectDirective = {
  mounted(el, binding) {
    const user = useUser()
    const { userPermi } = user
    const { value } = binding
    const permissionFlag = userPermi.some((item) => item.funcPerms === value)
    if (value) {
      if (!permissionFlag) el.parentNode && el.parentNode.removeChild(el)
    } else throw new Error(`请设置操作权限标签值`)
  }
}
